/**
 *
 */
package com.wedroid.r2d2.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.demo2do.core.persistence.GenericJdbcSupport;
import com.wedroid.entity.command.Command;
import com.wedroid.entity.command.GroupMentionLog;
import com.wedroid.r2d2.service.GroupMentionLogService;

/**
 * @author lute
 */
@Service("groupMentionLogService")
public class GroupMentionLogServiceImpl implements GroupMentionLogService {

    @Autowired
    private GenericJdbcSupport genericJdbcSupport;

    /* (non-Javadoc)
     * @see com.wedroid.r2d2.service.GroupMentionLogService#create(com.wedroid.entity.command.GroupMentionLog)
     */
    @Override
    public void create(GroupMentionLog groupMentionLog) {
        String sentence = "INSERT INTO group_mention_log (group_id, group_name, group_member_id, group_member_name, message_content, message_time, command_id) VALUES (:group.id, :groupName, :groupMember.id, :groupMemberName, :messageContent, :messageTime, :command.id)";
        // Ensure command id access will not throw NullPointerException
        if (groupMentionLog.getCommand() == null) {
            groupMentionLog.setCommand(new Command());
        }
        genericJdbcSupport.executeSQL(sentence, groupMentionLog);
    }

}
